home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 3313 < prev    next >
Encoding:
Text File  |  1996-08-05  |  948 b   |  42 lines

  1. Path: muss.CIS.McMaster.CA!not-for-mail
  2. From: shadowfax
  3. Newsgroups: comp.lang.c
  4. Subject: command line argument help
  5. Date: 27 Jan 1996 10:21:21 -0500
  6. Organization: McMaster University, Hamilton, Ontario, Canada.
  7. Sender: u9010255@muss.cis.McMaster.CA
  8. Message-ID: <4edfth$ok@muss.CIS.McMaster.CA>
  9. NNTP-Posting-Host: muss.cis.mcmaster.ca
  10.  
  11. to all the c gods out there:
  12.  
  13. i am not having too much success with command line arguments.  i am 
  14. trying to make a simple sumation executable for dos.  i am using borland 
  15. c++ v3.1.  what i want as the end result is the user just types:
  16.  
  17. c:\> sum 6 3
  18.  
  19. and the executable would output an answer of 9.  the following is my program:
  20.  
  21.  
  22. #include <stdio.h>
  23. #include <stdlib.h>
  24.  
  25. int main(char *argv[])
  26. {
  27.  
  28.    int iSum = 0;
  29.  
  30.    iSum = atoi(argv[1]) + atoi(argv[2]);
  31.    printf("\nthe answer is %d", iSum);
  32.  
  33.    return(0);
  34. }
  35.  
  36. when i compile and run, it always outputs an anser of 0.  can anyone tell 
  37. me what's wrong?
  38.  
  39. sf
  40.  
  41.  
  42.